<template>
    <div class="detail">
        <div class="top">
            <div class="t-msg flex-between">
                <div class="flex">
                    <img :src="detail.avatar" alt="">
                    <span>{{detail.nickname}}</span>
                </div>
                <div class="date">{{detail.create_time}}</div>
            </div>
            <p class="desc">{{detail.title}}</p>
            <div class="money flex-between">
                <div class="m_box flex-center">
                    <span>{{detail.cmoney}}</span>
                    <p>已筹金额(元)</p>
                </div>
                <div class="m-line"></div>
                <div class="m_box flex-center">
                    <span>{{detail.money}}</span>
                    <p>目标金额(元)</p>
                </div>
            </div>
        </div>
        <div class="bottom">
            <h3>发起人故事</h3>
            <p class="content">{{detail.describe}}</p>
<!--            <div class="showAll"><i class="iconfont iconxiajiantou-"></i> 展开全文</div>-->
            <div class="img-card flex" v-if="detail.images">
                <img :src="item" alt="" v-for="(item,index) in detail.images.split(',')" :key="index">
            </div>
        </div>
        <div class="bottom" v-if="detail.typeid == 2">
            <h3>发起人信息</h3>
            <div class="list flex-between">
                <span>发起人公司名称</span>
                <p>{{detail.ename}}</p>
            </div>
            <div class="pic">
                <span>发起人公司营业执照</span>
                <div>
                    <img :src="detail.image" alt="">
                </div>
            </div>
        </div>
        <div class="detail-footer flex">
            <div class="df-left flex-center" @click="getShareImg">
                <i class="iconfont iconfenxiang"></i> 分享
            </div>
            <div class="df-right  flex-center" @click="goHelp">我要帮助</div>
        </div>
        <filter-box v-if="showFilter">
            <div class="container flex-center" @click="showFilter = false">
                <img :src="share_img" alt="" @click.stop>
                <div class="share-btn flex-center" @click="downloadCodeImg">保存到相册</div>
            </div>
        </filter-box>
    </div>
</template>

<script>
    import FilterBox from '@/components/filterbox'
    export default {
        name: "detail",
        components:{
            FilterBox
        },
        data(){
            return {
                detail_id:null,
                detail:{},
                share_img:"",
                showFilter:false
            }
        },
        mounted(){
            this.detail_id = this.$route.query.id;
            this.getData()
        },
        methods:{
            goHelp(){
              this.$login(()=>{
                  this.$router.push({
                      path:'/help?id='+this.detail_id+'&uid='+this.detail.uid
                  })
              })
            },
            downloadCodeImg(){
                if(window.plus){
                    plus.gallery.save( this.share_img ,  ()=> {
                        this.$toast('保存成功')
                    } );
                }
            },
            getShareImg(){
                this.$login(()=>{
                    this.$http.post('index/detailShare',{
                        cid:this.detail_id
                    }).then(res=>{
                        console.log(res)
                        this.showFilter = true
                        this.share_img = res.data;
                    })
                })
            },
            getData(){
                this.$http.post('index/crowdfundingDetail',{
                    cid:this.detail_id
                }).then(res=>{
                    this.detail = res.data;
                })
            }
        }
    }
</script>

<style scoped lang="less">
    .detail{
        padding-bottom: 96px;
        .container{
            height: 100vh;
            flex-direction: column;
            img{
                width: 70%;
            }
            .share-btn{
                width: 85%;
                height:80px;
                border-radius: 40px;
                font-size: 32px;
                color:white;
                background: #185fff;
                margin-top: 100px;
            }
        }
    }
    .top{
        padding: 30px;
        background: white;
        .t-msg{
            img{
                width: 56px;
                height: 56px;
                border-radius: 50%;
                object-fit: cover;
            }
            span{
                font-size: 26px;
                color: #666666;
                margin-left: 15px;
            }
            .date{
                font-size: 26px;
                color: #666666;
            }
        }
        .desc{
            font-size: 30px;
            line-height: 48px;
            color: #333333;
            padding-top: 20px;
        }
        .money{
            margin-top: 40px;
            width: 100%;
            height: 120px;
            background-color: #f9f9f9;
            border-radius: 10px;
            padding: 0 22px;
            box-sizing: border-box;
            .m_box{
                flex-direction: column;
                span{
                    font-size: 30px;
                    color: #185fff;
                    font-weight: bold;
                }
                p{
                    font-size: 26px;
                    color: #666666;
                }
            }
            .m-line{
                width: 112px;
                height: 4px;
                background-color: #ddd;
                border-radius: 2px;
                position: relative;
                &::after{
                    content:"";
                    display: inline-block;
                    width: 4px;
                    height:20px;
                    background-color: #ddd;
                    position: absolute;
                    right:5px;
                    bottom:-2px;
                    transform: rotateZ(-45deg);
                }
            }
        }
    }
    .bottom{
        padding: 30px;
        margin-top: 20px;
        background: white;
        h3{
            font-size: 32px;
            color: #333333;
            margin-bottom: 20px;
        }
        .content{
            font-size: 28px;
            line-height: 45px;
            color: #666666;
        }
        .showAll{
            text-align: center;
            color:#185fff;
            font-size: 28px;
            padding: 30px 0;
        }
        .img-card{
            flex-wrap: wrap;
            margin-top: 30px;
            img{
                width: 214px;
                height: 214px;
                border-radius: 10px;
                margin-bottom: 20px;
                margin-right: 20px;
                object-fit: cover;
                &:nth-child(3n){
                    margin-right: 0;
                }
            }

        }
        .list{
            padding: 20px 0 40px;
        }
        span{
            font-size: 28px;
            color: #666666;
        }
        .pic img{
            margin-top: 20px;
            width: 400px;
            object-fit: cover;
        }
    }
    .detail-footer{
        position: fixed;
        bottom:0;
        width: 100%;
        height:96px;
        background: #b9cfff;
        color:white;
        .df-left{
            height:100%;
            width: 40%;
            font-size: 32px;
            color: #185fff;
            i{
                margin-right: 4px;
            }
        }
        .df-right{
            height:100%;
            width: 60%;
            background: #185fff;
            opacity: 1;
            font-size: 32px;
        }
    }
</style>
